export default function createElement (type, props, ...children) {
    const childElements = [].concat(...children).reduce((result, child) => {
        if (typeof child === 'boolean' || child === null) return result
        
        if (child instanceof Object) {
            result.push(child)
        } else {
            result.push(createElement('text', { textContent: child}))
        }

        return result
    }, [])
    
    return {
        type,
        // react 组件中，可以通过props.children 获取子元素
        props: Object.assign({ children: childElements }, props),
        children: childElements
    }
}